<template>
	<view class="warp">
		<view  v-if="!auditShow">
			<other></other>
		</view>
		<view class="name_info" v-if="auditShow">
			<view class="name">
				<view class="name_title">
					您的姓氏：
				</view>
				<view class="name_cont">
					{{objInfo.name}}
				</view>
			</view>
			<view class="time_title">
				<view class="line">
					
				</view>
				<view class="tt_cont">
					时辰四柱：
				</view>
			</view>
			<view class="bazi">
				<view class="bz_title">
					<view class="ba_item bazi_title">
						四柱
					</view>
					<view class="ba_item bazi_title">
						年柱
					</view>
					<view class="ba_item bazi_title">
						月柱
					</view>
					<view class="ba_item bazi_title">
						日柱
					</view>
					<view class="ba_item bazi_title">
						时柱
					</view>
				</view>
				<view class="bazi_tiangan">
					<view class="ba_item bazi_title">
						天干
					</view>
					<view class="ba_item">
						<view class="">
							{{baiziinfo.nianZhu.tianGan.tianGan}}
						</view>
						    <image v-if="baiziinfo.nianZhu.tianGan.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
							<image v-if="baiziinfo.nianZhu.tianGan.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
							<image v-if="baiziinfo.nianZhu.tianGan.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
							<image v-if="baiziinfo.nianZhu.tianGan.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
							<image v-if="baiziinfo.nianZhu.tianGan.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						
					</view>
					<view class="ba_item">
					{{baiziinfo.yueZhu.tianGan.tianGan}}
					<image v-if="baiziinfo.yueZhu.tianGan.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.tianGan.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.tianGan.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.tianGan.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.tianGan.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
											
					</view>
					<view class="ba_item">
						{{baiziinfo.riZhu.tianGan.tianGan}}
						<image v-if="baiziinfo.riZhu.tianGan.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.riZhu.tianGan.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.riZhu.tianGan.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.riZhu.tianGan.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.riZhu.tianGan.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
												
					</view>
					<view class="ba_item">
						{{baiziinfo.shiZhu.tianGan.tianGan}}
						<image v-if="baiziinfo.shiZhu.tianGan.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.shiZhu.tianGan.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.shiZhu.tianGan.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.shiZhu.tianGan.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.shiZhu.tianGan.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
												
					</view>
				</view>
				<view class="bazi_dizhi">
					<view class="ba_item bazi_title">
					地支
					</view>
					<view class="ba_item">
						{{baiziinfo.nianZhu.diZhi.diZhi}}
						<image v-if="baiziinfo.nianZhu.diZhi.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.nianZhu.diZhi.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.nianZhu.diZhi.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.nianZhu.diZhi.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
						<image v-if="baiziinfo.nianZhu.diZhi.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
												
					</view>
					<view class="ba_item">
					{{baiziinfo.yueZhu.diZhi.diZhi}}
					<image v-if="baiziinfo.yueZhu.diZhi.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.diZhi.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.diZhi.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.diZhi.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.yueZhu.diZhi.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
											
					</view>
					<view class="ba_item">
					{{baiziinfo.riZhu.diZhi.diZhi}}
					<image v-if="baiziinfo.riZhu.diZhi.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.riZhu.diZhi.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.riZhu.diZhi.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.riZhu.diZhi.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.riZhu.diZhi.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
											
					</view>
					<view class="ba_item">
					{{baiziinfo.shiZhu.diZhi.diZhi}}
					<image v-if="baiziinfo.shiZhu.diZhi.wuXing == '金'" src="../../../../static/images/other/jin.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.shiZhu.diZhi.wuXing == '木'" src="../../../../static/images/other/mu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.shiZhu.diZhi.wuXing == '水'" src="../../../../static/images/other/shui.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.shiZhu.diZhi.wuXing == '火'" src="../../../../static/images/other/huo.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
					<image v-if="baiziinfo.shiZhu.diZhi.wuXing == '土'" src="../../../../static/images/other/tu.png" mode="aspectFit" class="report2_content_tuwen_i"></image>
											
					</view>
				</view>
			</view>
			
			
		</view>
		<!-- 推荐 -->
		<view class="recommend_box" v-if="auditShow">
			<view class="recommend_optuion">
				<view class="rb_title">
					八字建议:
				</view>
				<view class="rb_cont" v-if="tuijian.baZiDetail">
					{{tuijian.baZiDetail}}
				</view>
			</view>
			<view class="recommend_box_names">
				<view class="rbn_title">
				<view class="rbn_title_left">
					推荐姓名
				</view>
				<view class="rbn_title_right" @click="changenumlist">
				<uni-icons type="refreshempty" size="16" color="#cecece"></uni-icons>
					换一换
				</view>
				</view>
				<view class="name_list">
					<view v-if="istishi.isyese" class="tishi" style="width: 100%;padding-bottom: 20rpx; font-size: 24rpx;color: #678cc2;">
						点击姓名可查看推荐详情 
					</view>
					<view @click="natTo('/pages/moreModule/name/nameInfo',item)" class="name_item" v-for="(item,index) in namelist" :key="index">
						<view class="name_cont">
							{{item.name}}
						</view>
						<view class="name_sorts">
							{{item.scores}}
						</view>
					</view>
					<view class="pagenum">
						<view class="p_left" @click="jiannumlist">
							<span>上一页</span>
						</view>
						<view class="p_right" @click="changenumlist">
							<span>下一页</span>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import other from '@/components/other/index.vue'
	export default {
		components:{other},
		data() {
			return {
				form:{
					year: '', 
					month: '', 
					day: '', 
					hour: '', 
					minute: '', 
					seconds: '', 
					dateType: '', //日期类型（0:公历。1:农历）
					leapMonth: ' ',// 闰月（false:不使用闰月。true:使用闰月）
					sex: '', 
					name: '' 
				},
				objInfo:{},
				baiziinfo:{},//八字信息
				tuijian:{},//推荐
				namelist:[],
				hform:{
					sex: "",
					name: "", 
					wuXing1:"", 
					wuXing2: "" ,
					pageSize:20,
					current:1
				},
				istishi:{isyese:true},
					auditShow:false,
			};
		},
		onLoad(options) {
			if ('nameobj' in options) {
				  console.log(obj);
			      let obj = JSON.parse(decodeURIComponent(options.nameobj));
				  console.log(obj);
				  this.objInfo=obj
				 // this.getList(obj.name)
				this.getbaziinfo()
			 }
		},
		onShow() {
			this.getAudit()
		},
		methods:{
			//获取微信审核开关
			getAudit(){
			    let param = {};
				param.url='v3/system/front/configuration/1'
				this.$request(param).then(res=>{
					console.log(res);
					this.auditShow=res.data.auditSwitch
					if(this.auditShow){
						uni.setNavigationBarTitle({
							title:'起名'
						})
					}
				})
			},
			// 获取八字信息
			getbaziinfo(){
				// 判断是阳历还是农历
				this.objInfo.selectAddressCode='110101'
				 if(this.objInfo.isLeap==null){
					 //阳历信息
					
					
					this.$request({
						urls:'scbz/bz/convertedCalendar',
						method:'POST',
						header:{
							'Content-Type': 'application/json;charset=utf-8',
						},
						data:this.objInfo
					}).then(res=>{
						this.baiziinfo=res.baZiWuXing
					})
				 }else{
					 // 农历信息
					 this.$request({
					 	urls:'scbz/bz/convertedSolarCalendar',
					 	method:'POST',
					 	header:{
					 		'Content-Type': 'application/json;charset=utf-8',
					 	},
					 	data:this.objInfo
					 }).then(res=>{
					 	this.baiziinfo=res.baZiWuXing
					 })
				 }
				 this.getrecommendname()
				
			},
			// 获取推荐姓名
			getrecommendname(){
				this.form.year=this.objInfo.year
				this.form.month=this.objInfo.month
				this.form.day=this.objInfo.day
				this.form.hour=this.objInfo.hour
				this.form.minute=0
				this.form.seconds=0
				this.form.dateType=this.objInfo.isLeap=='true' || this.objInfo.isLeap=="false"?'1':'0'
				this.form.leapMonth=this.objInfo.isLeap=='true'?true:false
				this.form.sex=this.objInfo.gender
				this.form.name=this.objInfo.name
				this.$request({
					url:'v3/name/grade/front/bz/recommended/detail',
					method:'POST',
					header:{
						'Content-Type': 'application/json;charset=utf-8',
					},
					data:this.form
					
				}).then(res=>{
					this.tuijian=res.data
					this.namelist=res.data.list
					let _this=this
					setTimeout(function(){
					_this.updatetishi()
					},5000)
					// console.log(res);
				})
			},
			updatetishi(){
				console.log('444');
				this.$set(this.istishi,"isyese","false")
				console.log(this.istishi);
			},
			// 换一批
			changenumlist(){
				this.istishi.isyese=false
				// this.$modal.msg('暂时没有更多了')
				this.hform.sex=this.objInfo.gender
				this.hform.name=this.objInfo.name
				if(this.tuijian.wuXing1){
					this.hform.wuXing1=this.tuijian.wuXing1
				}else{
					delete this.hform.wuXing1
				}
				if(this.tuijian.wuXing2){
					this.hform.wuXing2=this.tuijian.wuXing2
				}else{
					delete this.hform.wuXing2
				}
				
				this.hform.current++
				this.$request({
					url:'v3/name/grade/front/list',
					method:'GET',
					header:{
						'Content-Type': 'application/json;charset=utf-8',
					},
					data:this.hform
				}).then(res=>{
					console.log(res);
					if(res.data.list.length<1){
						this.hform.current--
						console.log(this.hform.current,'ll');
						this.$modal.msg('暂时没有更多了')
						// this.changenumlist()
						// this.hform.current--
					}else{
						this.namelist=res.data.list
					}
					
					
				})
			},
			// 上一页、下一页
			jiannumlist(){
				if(this.hform.current<=1){
					this.$modal.msg('当前已是第一页！')
					return
				}else{
					this.hform.current--
					console.log(this.hform.current,'kk');
					this.$request({
						url:'v3/name/grade/front/list',
						method:'GET',
						header:{
							'Content-Type': 'application/json;charset=utf-8',
						},
						data:this.hform
					}).then(res=>{
						this.namelist=res.data.list
					})
				}
			},
			// 跳转详情
			natTo(url,item){
				// 要传递的对象参数
				const obj = {
					nameGradeId:item.nameGradeId,
					name:item.name,
					year: this.objInfo.year,
					month: this.objInfo.month,
					day: this.objInfo.day,
					hour: this.objInfo.hour,
					minute: this.objInfo.minute,
					gender: this.objInfo.gender,
					isLeap: this.objInfo.isLeap,
				}
				// const obj = {
				// 	nameGradeId:item.nameGradeId,
				// 	name:item.name,
				// 	year:2020 ,
				// 	month: 12,
				// 	day: 10,
				// 	hour: 12,
				// 	minute: '00',
				// 	gender: '男',
				// 	isLeap: null,
				// }
				console.log('obj',obj);
				
				// 将对象参数转为JSON字符串，并使用encodeURIComponent编码
				const params = encodeURIComponent(JSON.stringify(obj));
				
				// 跳转页面并传递对象参数
				uni.navigateTo({
				   url: `${url}?params=${params}`
				});
			},
		}
	}
</script>

<style lang="scss">
page{
	width: 100%;
	font-size: 28rpx;
}
.warp{
	padding: 20rpx 0;
	.name_info{
		padding: 20rpx;
		background-color: #fff;
		border-radius: 10rpx;
		.name{
			display: flex;
			border-bottom: 2rpx solid #cecece;
			padding: 10rpx;
			.name_title{
				font-size: 30rpx;
				font-weight: 550;
				color: #000000;
			}
			.name_cont{
				font-size: 30rpx;
				font-weight: 550;
				color: #88b7ff;
			}
			
		}
		.time_title{
			padding: 20rpx 0;
			display: flex;
			align-items: center;
			border-bottom: 2rpx solid #cecece;
			.line{
				width: 8rpx;
				height: 50rpx;
				background-color: #88b7ff;
				margin-right: 10rpx;
				border-radius: 4rpx;
			}
			.tt_cont{
				color: #000;
				font-weight: 550;
				font-size: 30rpx;
			}
		}
		
		.bazi{
			padding: 10rpx;
			.bazi_tiangan,.bazi_dizhi,.bz_title{
				justify-content: space-between;
				display: flex;
				padding: 10rpx 0;
				.ba_item{
					text-align: center;
					display: flex;
					align-items: center;
					.report2_content_tuwen_i{
						width: 30rpx;
						height: 30rpx;
						margin-left: 6rpx;
					}
					 
				}
				.bazi_title{
					font-weight: 550;
					color: #bb8a5f;
				}
			}
		}
	}
	.recommend_box{
		padding: 10rpx;
		background-color: #fff;
		margin-top: 20rpx;
		border-radius: 10rpx;
		.recommend_optuion{
			padding: 10rpx 0;
			border-bottom: 2rpx solid #cecece;
			.rb_title{
				font-size: 30rpx;
				font-weight: 550;
				color: #000;
				padding: 10rpx 0 20rpx 10rpx ;
			}
			.rb_cont{
				font-size: 28rpx;
				color: #88b7ff;
				font-weight: 550;
				padding-left: 30rpx;
			}
		}
		.recommend_box_names{
			padding: 20rpx;
			.rbn_title{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.rbn_title_left{
					font-size: 30rpx;
					font-weight: 550;
					color: #000;
					padding: 10rpx 0 20rpx 10rpx ;
				}
				.rbn_title_right{
					font-size: 28rpx;
					color: #cecece;
					padding-right: 10rpx;
				}
				
			}
			
		}
		.name_list{
				padding: 50rpx 50rpx 20rpx 50rpx;
				border: 2rpx solid #cecece;
				border-radius: 10rpx;
				display: flex;
				flex-wrap: wrap;
			
				// justify-content: space-between;
				.name_item{
					display: flex;
					justify-content: space-between;
					align-items: center;
				width: 50%;
					// border: 2rpx solid #ddce5d;
				text-align: center;
				margin-bottom: 20rpx; 
				// margin-right: 10%;  
				padding: 0 20rpx;
					.name_cont{
						width: 60%;
						padding: 10rpx 16rpx;
						border: 4rpx solid #88b7ff;
						font-size: 30rpx;
						border-radius: 10rpx;
					}
					.name_sorts{
						font-size: 28rpx;
						color: #88b7ff;
						font-weight: 550;
					}
				}
				// 分页
			.pagenum{
				margin-top: 20rpx;
				width: 100%;
				display: flex;
				justify-content: space-between;
			     color: #cecece;
			}
			}
			
	}
}
</style>
